package com.woniuxy.rms.service.impl;

import com.woniuxy.rms.dao.PlotsMapper;
import com.woniuxy.rms.dao.PropertyMapper;
import com.woniuxy.rms.pojo.Plots;
import com.woniuxy.rms.pojo.Property;
import com.woniuxy.rms.service.PropertyService;
import com.woniuxy.rms.util.DataResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Auther: ChenGang  <br/>
 * Date: 2020/3/30 0030:下午 4:12  <br/>
 * Description:物业服务层
 */
@Service
public class PropertyServiceImpl implements PropertyService {
    @Autowired
    private PropertyMapper propertyMapper;

    @Autowired
    private PlotsMapper plotsMapper;
    @Override
    public List<Property> findByPage(Integer currentPage, Integer pageSize, String company, String companyPlace, Integer status) {
        return propertyMapper.findByPage(currentPage,pageSize,company,companyPlace,status);
    }

    @Override
    public DataResult checkPro(Property property) {
        property.setUpdateTime(new Date());
        propertyMapper.updateByPrimaryKeySelective(property);
        return DataResult.success();
    }

    @Override
    public DataResult deleteById(Long id) {
        propertyMapper.deleteByPrimaryKey(id);
        return DataResult.success();
    }

    @Override
    public DataResult exitPlot(Integer id) {
        plotsMapper.exitPlot(id);
        return DataResult.success();
    }
}